import requests
import bs4


def qunimadegbk(str):
    return str.encode('utf-8').decode('gbk')

def getosuskilldata(username):
    try:
        r = requests.get('http://osuskills.tk/user/' + username)
        soup = bs4.BeautifulSoup(qunimadegbk(r.text), "html.parser")
        return soup
    except :
        return 0

def getskill(soup):
    try:
        l = soup.find_all("output", "skillValue")
        skill = []
        for i in range(0,6):
            skill.append(int(l[i].get_text()))
        return skill
    except:
        return [0, 0, 0, 0, 0, 0, 0, 0]

def getranktitle(soup):
    try:
        l = soup.find_all("div", "userRankTitle")
        title = []
        for t in l:
            title.append(t.get_text())
        return title
    except :
        return []


